home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / comm / dcddv24.lha / Do_CRIS.rexx < prev    next >
OS/2 REXX Batch file  |  1994-10-03  |  10KB  |  406 lines

  1. /* 
  2.    Do_CRIS.rexx                   Version 1.3                     941003.1932
  3.  
  4.    This was written so that I could keep an eye on the "latest news" about
  5.    the Amiga buyout (whenever it gets here!) The AUTO mode is setup for this.
  6.  
  7. */
  8.  
  9.  
  10.  
  11. address BAUD /* must have this here */
  12. OPTIONS RESULTS
  13.  
  14. parse arg N_args
  15.  
  16. parse var N_args PW1 PW2 Xargs
  17.  
  18. auto = 'X'
  19. test = 'X'
  20. waitlost = ' '
  21.  
  22. /* below will stop the updating of the .newsrc file or DLing of news files */ 
  23.  
  24. if exists('ram:CRIS_TEST')~=0 then   
  25.    test = 'y'
  26.  
  27. if exists('ram:AUTO')~=0 then   
  28.    auto = 'y'
  29.  
  30. call LOGON
  31.  
  32. /* below allows the UPloading of RAM:.newsrc into your CRIS account to allow
  33.    for selecting a batch of new news groups and will then download this file
  34.    after it has been updated. (Magic Token act!) when both Crisinet.qwk and
  35.    .newsrc files have been downloaded they are renamed using date and time */
  36.  
  37. if auto = 'y' then do
  38.    if waitlost = 'n' then 
  39.       call AUTO_IGQWK
  40. end 
  41.  
  42. /* below allows you to use the AUTO mode and then change your mind and stay
  43.    connected. It's very usefull to be able to change your mind............ */
  44.  
  45. if exists('ram:SIT_STAY')=0 then do  
  46.    if auto = 'y' then do
  47.       if waitlost = 'n' then
  48.          call LOGOFF
  49.    end
  50. end  
  51.  
  52. if auto = 'y' then do
  53.    if waitlost = 'n' then 
  54.       call CLEANUP
  55. end
  56.  
  57.  
  58. /* below gets you out of any process that has had problems */
  59.  
  60. if waitlost ~= 'n' then do
  61.    if exists('RAM:continue')~=0 then do
  62.       address command 'delete RAM:continue'
  63.       exit
  64.    end
  65. end
  66.  
  67. return
  68.  
  69. /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  70.  *                                                             *
  71.  *                   Functions / Subroutines                   *
  72.  *                                                             *
  73.  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
  74.  
  75. LOGON:
  76. address BAUD /* must have this here */
  77.  
  78. send '\w\w\w\w\w\w\w'
  79. send '@D'
  80. send '\w\r'
  81.  
  82. waitlost = ' '
  83. waitlost_LO_hold = ' '
  84. PW_loop_count = 0
  85. Q2QUIT_loop_count = 0
  86. do forever
  87. nput='TERMINAL=,@,CRIS CONNECTED,Otherwise type,Enter your password:,or Q to QUIT,or X to EXIT,NO CARRIER'
  88. wait nput
  89. NRC = RC
  90. NRESULT = RESULT
  91.    if NRC > 0 then do  /* waited 30 seconds & no nput items on serial port */
  92.       waitlost = 'y'
  93.       msg '****** LOGON - wait is LOST! ******'
  94.       Capture OFF
  95.       leave  
  96.    end
  97.  
  98.    if NRESULT = 'TERMINAL=' then              
  99.       send '\r'
  100.  
  101.    if NRESULT = '@  ' then do
  102.       if exists('RAM:continue')~=0 then do
  103.          send 'C CRIS'
  104.          send '\r'
  105.       end
  106.    end
  107.  
  108.    if NRESULT = 'CRIS CONNECTED' then        
  109.       call time(R)
  110.  
  111.    if NRESULT = 'Otherwise type' then                
  112.       send 'jws\r'
  113.  
  114.    if NRESULT = 'Enter your password:' then do              
  115.       PW_loop_count = PW_loop_count + 1
  116.       if PW_loop_count = 1 then 
  117.          send PW1'\w\r'                            
  118.       if PW_loop_count = 2 then do
  119.          if exists('DH1:-dl/CRIS_PW2_used')=0 then
  120.             address command 'makedir DH1:-dl/CRIS_PW2_used' 
  121.          send PW2'\w\r'
  122.       end                                        
  123.       if PW_loop_count > 2 then do
  124.          waitlost = 'y' 
  125.          msg '****** Logon PW_loop_count > 2 ******'
  126.          Capture OFF
  127.          leave  
  128.       end
  129.    end
  130.  
  131.  
  132.    if NRESULT = 'or Q to QUIT' then do           
  133.       send '\r' 
  134.       waitlost = 'n' 
  135.    end
  136.  
  137.    if NRESULT = 'or X to EXIT' then do                        
  138.       waitlost = 'n' 
  139.       send '\w\w'
  140.       send 'X'
  141.    end                               
  142.  
  143.    if NRESULT = 'NO CARRIER' then do             /* if logon really gets  */
  144.       waitlost = 'y'                             /*          LOST         */
  145.       leave                                      /* this will get you OUT */
  146.    end
  147.  
  148.    if waitlost ~= ' ' then do
  149.       send '\w\w'
  150.       leave
  151.    end
  152. end
  153. return
  154.  
  155. AUTO_IGQWK:
  156. OPTIONS RESULTS
  157. address command
  158.  
  159. address BAUD /* must have this here */ 
  160.  
  161. waitlost = ' '
  162. PSO_loop_count = 0
  163. SAO_loop_count = 0
  164. CI_loop_count = 0
  165. SELECT_loop_count = 0
  166. Q2QUIT_loop_count = 0
  167. DONE_ONCE = 'n'  
  168.  
  169. send '\w\w'
  170. send '3'
  171. send '\r'
  172.  
  173. do forever  
  174. nput='Please Select an Option:,Select An Option Or,S-INET, Select (1,Enter choice,(y/n),or Q to QUIT,Dialing aborted!' 
  175. wait nput  
  176. NRC = RC
  177. NRESULT = RESULT
  178.    if NRC > 0 then do  /* waited 30 seconds & no nput items on serial port */ 
  179.       waitlost = 'y'
  180.       msg '****** AUTO_IGQWK - wait is LOST! ******'
  181.       Capture OFF
  182.       leave  
  183.    end
  184.    if NRESULT = 'Dialing aborted!' then do
  185.       waitlost = 'y'
  186.       msg '****** AUTO_IGQWK - Dialing aborted ******'
  187.       Capture OFF
  188.       leave  
  189.    end
  190.    if NRESULT = 'Select An Option Or' then do
  191.       SAO_loop_count = SAO_loop_count + 1
  192.       if SAO_loop_count = 1 then do                   
  193.          send '\w\w'
  194.          send '8'
  195.          send '\r'
  196.       end              
  197.       if SAO_loop_count = 2 then do 
  198.          waitlost = 'n' 
  199.          send '\w\w'
  200.          send 'x' 
  201.          send '\r'                                
  202.       end
  203.       if SAO_loop_count > 2 then do
  204.          waitlost = 'y'
  205.          msg '****** AUTO_IGQWK - SAO_loop_count > 2 ******'
  206.          Capture OFF
  207.          leave  
  208.       end
  209.    end
  210.  
  211.    if NRESULT = 'S-INET' then do                       
  212.       if CI_loop_count = 0 then do                   
  213.          if exists('ram:.newsrc')~=0 then do
  214.             if DONE_ONCE = 'n' then do
  215.                address command 'copy RAM:.newsrc RAM:-dl/.newsrc'    
  216.                send '\w\w\w\w'
  217.                send 'rz -b -w 2048'
  218.                send '\r' 
  219.                send '\w\w'
  220.                send '\au-.newsrc'
  221.                send '\w\w'
  222.                DONE_ONCE = 'y'
  223.                if exists('RAM:-dl/.newsrc')~=0 then do  
  224.                   address command 'delete RAM:-dl/.newsrc'    
  225.                end
  226.             end
  227.          end
  228.          send '\w\w'
  229.          send '\r' 
  230.       end
  231.  
  232.       CI_loop_count = CI_loop_count + 1
  233.  
  234.       if CI_loop_count = 1 then do                   
  235.          send '\w\w'
  236.          send 'igqwk'
  237.          send '\r'
  238.       end
  239.                
  240.       if CI_loop_count = 2 then do 
  241.          send '\w\w'
  242.          send 'sz -b -w 2048 .newsrc'
  243.          send '\r'
  244.          send '\w\w\w\w\w\w'
  245.       end                    
  246.       if CI_loop_count = 3 then do 
  247.          send '\w\w'
  248.          send 'x'
  249.          send '\r'
  250.       end                    
  251.       call delay(1) 
  252.       if CI_loop_count > 4 then do
  253.          waitlost = 'y'
  254.          msg '****** AUTO_IGQWK - CI_loop_count > 4 ******'
  255.          Capture OFF
  256.          leave  
  257.       end
  258.    end
  259.  
  260.    if NRESULT = ' Select (1' then do                       
  261.       SELECT_loop_count = SELECT_loop_count + 1
  262.       if SELECT_loop_count = 1 then do                   
  263.          send '\w\w' 
  264.          send '1'
  265.          send '\r'
  266.       end                               
  267.       if SELECT_loop_count = 2 then do 
  268.          send '\w\w'
  269.          send '2'
  270.          send '\r'                 
  271.       end
  272.       if SELECT_loop_count > 2 then do
  273.          waitlost = 'y'
  274.          msg '****** AUTO_IGQWK - SELECT_loop_count > 2 ******'
  275.          Capture OFF
  276.          leave  
  277.       end
  278.    end
  279.  
  280.    if NRESULT = 'or Q to QUIT' then do                       
  281.       Q2QUIT_loop_count = Q2QUIT_loop_count + 1
  282.       if Q2QUIT_loop_count = 1 then do                   
  283.          send '\w\w'
  284.          send '\r'
  285.       end                               
  286.       if Q2QUIT_loop_count = 2 then do 
  287.          send '\w\w'
  288.          send '\r'                                
  289.       end
  290.       if Q2QUIT_loop_count > 2 then do
  291.          waitlost = 'y'
  292.          msg '****** AUTO_IGQWK - Q2QUIT_loop_count > 2 ******' 
  293.          Capture OFF
  294.          leave  
  295.       end
  296.    end
  297.  
  298.    if NRESULT = 'Enter choice' then do
  299.       if test = 'y'then do  
  300.          send '\w\w'
  301.          send '1'
  302.          send '\r'
  303.       end
  304.       if test ~= 'y' then do  
  305.          send '\w\w'
  306.          send '2'
  307.          send '\r'
  308.       end
  309.    end
  310.    if NRESULT = '(y/n)' then do                                       
  311.       if test = 'y' then do  
  312.          send '\w\w'
  313.          send 'n'
  314.          send '\r'
  315.       end
  316.       if test ~= 'y' then do  
  317.          send '\w\w'
  318.          send 'y'
  319.          send '\r'
  320.       end
  321.    end
  322.    if waitlost ~= ' ' then
  323.       leave
  324. end
  325. return
  326.  
  327. LOGOFF:
  328. address BAUD /* must have this here */
  329. OPTIONS RESULTS
  330. address command
  331.  
  332. address BAUD /* must have this here */ 
  333.  
  334. waitlost = ' '
  335. do forever  
  336. nput='Please Select an Option:,or R to re-logon)?,@' 
  337. wait nput  
  338. NRC = RC
  339. NRESULT = RESULT
  340.    if NRC > 0 then do  /* waited 30 seconds & no nput items on serial port */ 
  341.       waitlost = 'y'
  342.       msg '****** AUTO_LOGOFF - wait is LOST! ******'
  343.       Capture OFF
  344.       leave
  345.    end
  346.    if NRESULT = 'Please Select an Option:' then do                                
  347.       send '\w\w'
  348.       send 'g'
  349.       send '\r'
  350.    end 
  351.    if NRESULT = 'or R to re-logon)?' then do
  352.       send '\w\w'
  353.       send 'y'
  354.       send '\r'
  355.    end
  356.    if NRESULT = '@' then do
  357.       waitlost = 'n'
  358.       send '\w\w'
  359.       send 'hang'
  360.       send '\r'
  361.    end
  362.    if waitlost ~= ' ' then
  363.       leave
  364. end
  365. return
  366.  
  367. CLEANUP:
  368. OPTIONS RESULTS
  369. address command
  370.  
  371. dateYYMMDD=right(date(sorted),6)              
  372.  
  373. timea=translate(time(n),' ',':')              
  374. parse value timea with timeHH timeMM timeSS .  
  375. timeHHMMSS=timeHH||timeMM||timeSS 
  376.  
  377. if exists('RAM:-dl/crisinet.qwk')~=0 then do
  378.  
  379. /*  
  380.    address command 'rename RAM:-dl/crisinet.qwk RAM:-dl/crisinet.qwk.'dateYYMMDD'.'timeHHMM    
  381.  
  382. ************************************************************************
  383.     can anyone tell me why the above line will not work, while the next
  384.     two will, please let me know. I'm stumped!
  385. ************************************************************************
  386. */
  387.    address command 'copy RAM:-dl/crisinet.qwk RAM:-dl/crisinet.qwk.'dateYYMMDD'.'timeHHMMSS    
  388.    address command 'delete RAM:-dl/crisinet.qwk'
  389. end
  390.     
  391. if exists('RAM:-dl/.newsrc')~=0 then do  
  392.    address command 'copy RAM:-dl/.newsrc RAM:-dl/crisinet.tkn.'dateYYMMDD'.'timeHHMMSS    
  393.    address command 'delete RAM:-dl/.newsrc'    
  394. end
  395.     
  396. if exists('RAM:.newsrc')~=0 then do  
  397.    address command 'copy RAM:.newsrc RAM:UL_newsrc.'dateYYMMDD'.'timeHHMMSS    
  398.    address command 'delete RAM:.newsrc'    
  399. end
  400.     
  401. if exists('RAM:SIT_STAY')~=0 then   
  402.    address command 'delete RAM:SIT_STAY'    
  403.  
  404. return
  405.  
  406.